package com.zlhj.ex.Controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zlhj.ex.Common.Res;
import com.zlhj.ex.entity.Shi;
import com.zlhj.ex.service.ShiService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author zsx
 * @date 2021/06/16 10:58
 */
@Controller
@RequestMapping("/shi")
@Api(value = "shi")
public class ShiController {

    @Autowired
    private ShiService shiService;


    @ApiOperation(value = "getShiList")
    @CrossOrigin
    @ResponseBody
    @GetMapping("/getShiList/{id}")
    public Res getShiList(@PathVariable String id){
        QueryWrapper<Shi> wrapper = new QueryWrapper<>();
        wrapper.eq("sheng_id",id);
        List<Shi> shiList = shiService.list(wrapper);
        if (shiList.size() > 0){
            return new Res("200","success",shiList);
        } else if (shiList.size() == 0){
            return new Res("数据为空");
        }
        return new Res("error");
    }

}
